<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px; text-align: center">
    <legend>投票{if condition="$voteInfo"}修改 {else /}新增 {/if}</legend>
</fieldset>
<form class="layui-form" action="/admin/vote/editPost" style="width: 600px; margin: 0 auto">
    <input type="hidden" name="id" value="{$id}">
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">投票选项</label>
        <div class="layui-input-block">
            <table class="layui-table">
                <colgroup>
                    <col width="150">
                    <col width="150">
                    <col width="200">
                    <col>
                </colgroup>
                <thead>
                <tr>
                    <th>选择内容</th>
                </tr>
                </thead>
                <tbody>
                <tr><td><input type="text" name="option[]" class="layui-input" value=""></td></tr>
                <tr><td><input type="text" name="option[]" class="layui-input" value=""></td></tr>
                <tr><td><input type="text" name="option[]" class="layui-input" value=""></td></tr>
                <tr><td><input type="text" name="option[]" class="layui-input" value=""></td></tr>
                <tr><td><input type="text" name="option[]" class="layui-input" value=""></td></tr>
                <tr><td><input type="text" name="option[]" class="layui-input" value=""></td></tr>
                <tr><td><input type="text" name="option[]" class="layui-input" value=""></td></tr>
                <tr><td><input type="text" name="option[]" class="layui-input" value=""></td></tr>
                <tr><td><input type="text" name="option[]" class="layui-input" value=""></td></tr>
                <tr><td><input type="text" name="option[]" class="layui-input" value=""></td></tr>
                <tr><td><input type="text" name="option[]" class="layui-input" value=""></td></tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">描述</label>
        <div class="layui-input-block">
            <textarea name="description" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            <a href="/admin/vote/index" class="layui-btn layui-btn-primary">返回</a>
        </div>
    </div>
</form>

<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;
        var $ = layui.jquery;

        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.msg(JSON.stringify(data.field));
            $.post({
                url: '/admin/vote/editPost/',
                dataType: 'json',
                data: data.field,
                success(res) {
                    if (res.status === 200) {
                        location.href = '/admin/vote/index/';
                    } else {
                        layer.msg(res.info);
                    }
                }
            })
            return false;
        });
    });
</script>